color = "blue"
stage.set_axis(9)
stage.create_grid_overlay(1, color)
sprite = codesters.Circle(0, 0, 1, "green")
sprite.set_size(.5)
def main_event():
global rand_x
global rand_y
global guide
global asker
sprite.go_to(0,0)
guide = codesters.Text(" ", 0, 7, color)
pos_val = list(range(1,8))
neg_val = list(range(-7, 0))
rand_x = random.choice(pos_val + neg_val)
rand_y = random.choice(pos_val + neg_val)
point = (rand_x, rand_y)
asker = codesters.Text("Click on " + str(point), 0, 7.5, "black")
main_event()
score = 0
def wait():
stage.wait(.001)
def click():
global score
asker.set_text(' ')
x = stage.click_x()
y = stage.click_y()
sprite.go_to(x, y)
stage.event_click(wait)
if 0<=abs(x-rand_x)<1 and 0<=abs(y-rand_y)<1:
choice = 1
elif (0<=abs(y - rand_x) <1) and (0<= abs(x - rand_y) <1):
choice = 2
else:
choice = False
stage.wait(1)
guide.go_to(rand_x, rand_y + 2)
if choice == 2:
guide.set_text("Oops! Looks like you mixed up x and y. \n Try again!")
guide.set_color("sienna")
elif choice == 1:
guide.set_text("Great job!")
guide.set_color("black")
score += 1
else:
guide.set_text("Here it is!")
sprite.go_to(rand_x, rand_y)
stage.wait(1)
guide.set_text("Try again!")
guide.set_color('red')
stage.wait(1)
guide.set_text(' ')
if score < 6:
main_event()
if score >= 6:
guide.go_to(0, 7.5)
guide.set_color("green")
guide.set_text(" ")
tm = TestManager()
tm.display_success_message("Great job! You've mastered the coordinate plane!")
stage.event_click(click)
stage.event_click(click)
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)